package com.Threecharacters.Poly_.ReWrite;

public class case1 {
    public static void main(String[] args) {

        //属性重写看编译类型
        Base base = new Sub();
        System.out.println(base.a);//编译类型为Base,则值为10

        Sub sub = new Sub();
        System.out.println(sub.b);//编译类型为Sub,则值为20

        //instanceof判断对象的运行类型是否为某某类型或者某某类型的子类型
        Base base1 = new Base();
        System.out.println(base1 instanceof Base);//true
        System.out.println(base1 instanceof Sub);//false



    }
}

class Base{
    int a = 10;
}
class Sub extends Base{
    int b = 20;
}


